/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AlumnoView.java
 *
 * Created on 26-abr-2012, 14:20:50
 */
package educar.abmAlumno;

import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.table.DefaultTableModel;


public class AlumnoView extends javax.swing.JFrame {
    
// <editor-fold defaultstate="collapsed" desc="Constructor">
       public AlumnoView() {
        initComponents();
    }
// </editor-fold>
       
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jbAgregar = new javax.swing.JButton();
        jbEliminar = new javax.swing.JButton();
        jbBuscar = new javax.swing.JButton();
        jadministracionAlumnos = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtAlumnos = new javax.swing.JTable();
        jlCriterio = new javax.swing.JLabel();
        jtfCriterio = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jbAgregar.setText("Agregar");

        jbEliminar.setText("Eliminar");

        jbBuscar.setText("Buscar");

        jadministracionAlumnos.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jadministracionAlumnos.setText("Administracion de Alumnos");

        jtAlumnos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "", "nroalumno", "dni", "nombreYapellido", "direccion"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Boolean.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jtAlumnos);
        jtAlumnos.getColumnModel().getColumn(0).setResizable(false);
        jtAlumnos.getColumnModel().getColumn(0).setPreferredWidth(15);
        jtAlumnos.getColumnModel().getColumn(1).setMinWidth(15);
        jtAlumnos.getColumnModel().getColumn(3).setMinWidth(100);

        jlCriterio.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
        jlCriterio.setText("Nombre de Alumno");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(77, 77, 77)
                .addComponent(jadministracionAlumnos)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jbAgregar)
                .addGap(10, 10, 10)
                .addComponent(jbEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jbBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jlCriterio))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(jtfCriterio)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jadministracionAlumnos, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jlCriterio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbAgregar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfCriterio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

//<editor-fold defaultstate="collapsed" desc=" Declaracion de Variables ">  
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel jadministracionAlumnos;
    private javax.swing.JButton jbAgregar;
    private javax.swing.JButton jbBuscar;
    private javax.swing.JButton jbEliminar;
    private javax.swing.JLabel jlCriterio;
    private javax.swing.JTable jtAlumnos;
    private javax.swing.JTextField jtfCriterio;
    // End of variables declaration//GEN-END:variables
        //</editor-fold>
    
// <editor-fold defaultstate="collapsed" desc="Acciones">
    public JTable getJTAlumnos() {
        return jtAlumnos;
    }

    public DefaultTableModel getModeloTabla(){
        return (DefaultTableModel) jtAlumnos.getModel();
    }
    
    public void setModeloTabla(DefaultTableModel tabla){
        if (tabla != null){
            this.jtAlumnos.setModel(tabla);
        } else {
            jtAlumnos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "", "nroalumno", "dni", "nombreYapellido", "direccion"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Boolean.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        }    
        jtAlumnos.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(jtAlumnos);
        jtAlumnos.getColumnModel().getColumn(0).setResizable(false);
        jtAlumnos.getColumnModel().getColumn(0).setPreferredWidth(50);
        jtAlumnos.getColumnModel().getColumn(1).setPreferredWidth(160);
        jtAlumnos.getColumnModel().getColumn(2).setPreferredWidth(160);
        jtAlumnos.getColumnModel().getColumn(3).setPreferredWidth(160);
        jtAlumnos.getColumnModel().getColumn(3).setPreferredWidth(160);
    }

    public JButton getJbAgregar() {
        return jbAgregar;
    }

    public JButton getJbBuscar() {
        return jbBuscar;
    }

    public JButton getJbEliminar() {
        return jbEliminar;
    }

   public String getCriterio() {
        return jtfCriterio.getText();
    }
    

    public void setActionListener(AlumnoController listener) {
        jbAgregar.addActionListener(listener);
        jbEliminar.addActionListener(listener);
        jbBuscar.addActionListener(listener);
    }

    

    public void setMouseListener(AlumnoController listener) {
        jtAlumnos.addMouseListener(listener);
    }

    public void setWindowListener(AlumnoController listener){
        this.addWindowListener(listener);
    }
   // </editor-fold> 
}
